Imports iConverter.Contracts
Imports System.Drawing
Imports System.Configuration
Imports iConverter.Models
Imports iConverter.Core

Namespace Extensions
    ''' <summary>
    ''' 发送到插件
    ''' </summary>
    ''' <remarks></remarks>
    Public Class Send
        Inherits Plugin
    


        ''' <summary>
        ''' 创建新的插件实例
        ''' </summary>
        ''' <param name="provider">提供插件的提供器</param>
        ''' <param name="plugin">插件对象</param>
        ''' <remarks></remarks>
        Friend Sub New(ByVal provider As PluginProvider, ByVal plugin As Object)
            MyBase.New(provider, plugin)

            Me._plugin = DirectCast(plugin, ISend)
            Me._plugin = DirectCast(plugin, ISendMetadata)
        End Sub



        ''' <summary>
        ''' 插件对象
        ''' </summary>
        ''' <remarks></remarks>
        Dim _plugin As ISend

        ''' <summary>
        ''' 插件对象
        ''' </summary>
        ''' <remarks></remarks>
        Private ReadOnly Property Plugin() As ISend
            Get
                Return _plugin
            End Get
        End Property

        ''' <summary>
        ''' 插件元数据
        ''' </summary>
        ''' <remarks></remarks>
        Dim _metadata As ISendMetadata

        ''' <summary>
        ''' 插件元数据
        ''' </summary>
        ''' <remarks></remarks>
        Private ReadOnly Property Metadata() As ISendMetadata
            Get
                Return _metadata
            End Get
        End Property




#Region "发送到处理方法"

        ''' <summary>
        ''' 将转换文档发送到其他位置的方法
        ''' </summary>
        ''' <param name="doc">要发送的转换文档</param>
        ''' <remarks></remarks>
        Public Sub SendTo(doc As ConvertDocument)
            'TODO: 检查或移动代码

            If doc.IsChanged OrElse Not doc.IsFromFile Then
                doc.Save(SettingManager.Settings.isBackupSaveDocument)

            End If

            Me.Plugin.Sending(doc)

        End Sub


#End Region


#Region "IDisposable Support"
       

        ' IDisposable
        Protected Overrides Sub Dispose(disposing As Boolean)
            If Not Me.disposedValue Then
                If disposing Then

                End If

                Me._metadata = Nothing
                Me._plugin = Nothing

            End If
            Me.disposedValue = True
        End Sub

#End Region

    End Class

End Namespace
